package com.supermali.behavior.forward.land;

import com.supermali.behavior.forward.MoveForwordBehavior;
import com.supermali.entity.npc.person.Person;
import com.supermali.util.Constant;

public class LandPersonMoveForword extends MoveForwordBehavior {

    private Person person;

    MoveRateControl moveRateControl;

    public LandPersonMoveForword(Person person) {
        this.person = person;
        moveRateControl = new MoveRateControl();
    }

    @Override
    public void forward(long delta) {
        person.setRunState(Person.RunState.FORWARD);
        person.setDirect(Person.Direct.Right);
        // 前进
        double x = person.getX();
        if(x* Constant.scale < Constant.FrameWidth/2){
            double move = moveRateControl.move(delta, 1);
            x+=move;
            person.setX(x);
        }
    }
}
